﻿#nullable disable
using System;
using System.Runtime.CompilerServices;

namespace Camera2Demo
{
    public class Awaiter : INotifyCompletion
    {
        private Action _continuation;

        public bool IsCompleted { get; private set; }

        public void Completed()
        {
            IsCompleted = true;
            _continuation?.Invoke();
        }
        public void GetResult()
        {
        }
        public void OnCompleted(Action continuation)
        {
            if (IsCompleted)
                _continuation?.Invoke();
            else
                _continuation += continuation;
        }
    }
}